package com.xuyuan.io;

import org.junit.jupiter.api.Test;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * NIO常用的两大工具类Files、Paths
 *
 * @author xuyuan
 */
public class JdkNioFilesRead {

    private static final String FILE_PATH = "C:/Software/IDEA2022/workspace/reflect/classes" + File.separator + "json.txt";
    private static final Path DIR_PATH = Paths.get(FILE_PATH);

    @Test
    public void test() throws Exception {
        // 获取指定路径
        Path path = Paths.get(FILE_PATH);
    }

    @Test
    public void test2() throws Exception {
        InputStream inputStream = Files.newInputStream(DIR_PATH);
        OutputStream outputStream = Files.newOutputStream(Paths.get(DIR_PATH + File.separator + "test3.txt"));
        BufferedReader bufferedReader = Files.newBufferedReader(DIR_PATH);
        BufferedWriter bufferedWriter = Files.newBufferedWriter(Paths.get(DIR_PATH + File.separator + "test4.txt"));
    }
}
